package cn.com.git.workflow.api;


import cn.com.git.common.base.BaseApi;
import cn.com.git.common.model.ResultConstant;
import cn.com.git.common.model.ResultPage;
import cn.com.git.workflow.service.WorkFlowConfigService;
import cn.com.git.workflow.service.dto.WorkFlowConfigListDTO;
import cn.com.git.workflow.service.query.WorkFlowConfigListQuery;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * 系统资源
 * @author zhangzhenfu
 * @Description
 * @date 2020/2/22 15:32
 */
@Api(value = "流程配置", description = "流程配置")
@RestController
@RequestMapping("/work_flow_config")
public class WorkFlowConfigApi extends BaseApi {

    @Autowired
    private WorkFlowConfigService workFlowConfigService;

    @ApiOperation(value = "列表查询", notes = "列表查询", httpMethod = "POST",consumes = MediaType.APPLICATION_JSON_UTF8_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @PostMapping(value = "/list/page",consumes = MediaType.APPLICATION_JSON_UTF8_VALUE, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public ResultPage<WorkFlowConfigListDTO> listPage(@Valid @RequestBody WorkFlowConfigListQuery query) {
        ResultPage<WorkFlowConfigListDTO> resultPage ;
        try {
            resultPage = workFlowConfigService.listWorkFlowConfig(query);
        }catch (Throwable e){
            resultPage = new ResultPage<>(ResultConstant.FAILED);
            logger.error("列表查询失败：{}",e.getMessage());
        }
        return resultPage ;
    }



}
